#pragma once

#include <QObject>
#include <mutex>
#include <memory>
#include <QThread>
#include "MediaSession.h"

namespace jlh {

	class RtspServerWorker;
	class RtspServer : public QObject
	{
		Q_OBJECT

	public:
		static std::shared_ptr<RtspServer> Create();
		virtual ~RtspServer();
		void Start(const char* ip, uint16_t port);
		void Stop();

		MediaSessionId AddSession(MediaSession* session);

		bool PushFrame(MediaSessionId sessionId, MediaChannelId channelId, std::shared_ptr<uint8_t>& data, int frame_size, int64_t timestamp);

	private:
		RtspServer(QObject *parent = nullptr);


	private:
		QThread worker_thread_;
		std::mutex mutex_;
		std::shared_ptr<RtspServerWorker> rtsp_worker_;
	};

}